package com.koron.css2.serviceManage.impl;

import com.koron.css2.ServerInterface;
import com.koron.css2.serviceManage.bean.BankConfigBean;
import com.koron.css2.serviceManage.bean.RequestBean;
import com.koron.css2.serviceManage.bean.UserInfoBean;
import com.koron.css2.serviceManage.mapper.BankConfigMapper;
import com.koron.util.Constant;
import com.koron.util.JsonUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.koron.ebs.mybatis.SessionFactory;
import org.swan.bean.MessageBean;

/**
 * 添加银行出回盘配置
 * 
 * @author 李攀
 *
 */
public class BankConfigAdd implements ServerInterface {

	private static Logger logger = LogManager.getLogger(BankConfigAdd.class);

	@Override
	public MessageBean<?> exec(SessionFactory factory, UserInfoBean userInfo, RequestBean req) {
		try {
			//获取参数
			BankConfigBean bean = JsonUtils.objectToPojo(req.getData(), BankConfigBean.class);
			//获取mapper
			BankConfigMapper mapper = factory.getMapper(BankConfigMapper.class);
			//添加
			bean.setCreateInfo(userInfo);
			mapper.insertBankConfig(bean);
			return MessageBean.create(Constant.MESSAGE_INT_SUCCESS, "success", void.class);
		} catch (Exception e) {
			logger.error("银行出回盘配置增加失败", e);
			return MessageBean.create(Constant.MESSAGE_INT_FAIL, "增加失败", void.class);
		}
	}

}
